package edu.zut.cs.software.perfect.teacher.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.base.service.impl.GenericTreeManagerImpl;
import edu.zut.cs.software.perfect.teacher.dao.DepartmentDao;
import edu.zut.cs.software.perfect.teacher.domain.Department;
import edu.zut.cs.software.perfect.teacher.domain.Teacher;
import edu.zut.cs.software.perfect.teacher.service.DepartmentManager;

/**
 * @ClassName DepartmentManagerImpl
 * @Description TODO
 * @Author lixianglong
 * @Date 2020年6月2日 am11:15:15
 * @Version 1.0
 */
@Service(value="departmentManager")
public class DepartmentManagerImpl extends GenericTreeManagerImpl<Department, Long> implements DepartmentManager {

	DepartmentDao departmentDao;
   @Autowired
	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	   this.treeDao=this.departmentDao;
	   this.dao=this.departmentDao;
	}
@Override
public List<Department> findAll() {
	return (List<Department>) this.dao.findAll();
}
@Override
public Optional<Department> findByCourseId(Long courseId) {
	Optional<Department> result=this.dao.findById(courseId);
	return result;
}
@Override
public Boolean deleteById(Long courseId) {
	Optional<Department> department=this.dao.findById(courseId);
	if(department.equals(Optional.empty())) {
		return false;
	}else {
		this.dao.delete(department.get());
		return true;
	}
}
	
	
}
